using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class pages_CheckoutTourBooking : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        PackageBooking pb = Session["p_booking"] as PackageBooking;
        User user = Session["user"] as User;
        if (pb == null)
        {
            lblMessage.Text="<h2>Sorry! Some errors has occured in our system.<br/>Please try later or contact us now.</h2>";
            return;
        }
        if (pb.ID <= 0)
        {
            lblMessage.Text = "<h2>Sorry! Some errors has occured in our system.<br/>Please try later or contact us now.</h2>";
            return;
        }
        if (user != null)
        {
            lblCustomerName.Text = user.PersonInfor.FirstName + " " + user.PersonInfor.LastName;
            lblAddress.Text = user.PersonInfor.Address;
            lblEmail.Text = user.PersonInfor.Email;
            lblPhone.Text = user.PersonInfor.Phone;
            lblTourName.Text = pb.Tour.Name;
            lblPrice.Text = pb.Price.ToString();
            lblNumberOfGuests.Text = pb.GuestNumber.ToString();
            lblDepartureDate.Text = pb.DepartureTime.ToShortDateString();
            lblMidifiedDate.Text = pb.ModifiedDate.ToString("MM/dd/yyyy - hh:mm tt");
            SendMail(pb.Tour.Name,pb.Price,pb.GuestNumber,pb.DepartureTime,pb.Note,pb.ModifiedDate);
        }
        

    }
    public void SendMail(string tourName, decimal price, int guestNumber, DateTime departureDate,string requirements, DateTime modifiedDate)
    {
        User user = Session["user"] as User;
        string st = "This is checkout email from KarnelTravel company.<br/><br>";
        st += "Dear customer! You have booked successfully a tour at our website. This is checkout and confirm email we send to you.";
        st += "Please check again to make sure that below information is correct.<br/>";
        st += "Your name: " + user.PersonInfor.FirstName + " " + user.PersonInfor.LastName + "<br/>";
        st += "Your phone: " + user.PersonInfor.Phone + "<br/>";
        st += "Booked Tour: "+tourName+"<br/>";
        st += "Number of guests: "+guestNumber.ToString()+"</br>";
        st += "Departure date: "+departureDate.ToString("MMM, dd yyyy") +"<br/>";
        st += "Price: $" + price.ToString("#0.#") +"<br/>";
        st += "This booking is create at: " + modifiedDate.ToString("MMM, dd yyyy - hh:mm")+"<br/>";
        st += "Thank you for using our service. For more information and support, please contact us though phone number: 1234567890 or visit out website at KarnelTravel.com";
        if (requirements != "") st += "Requirement: " + requirements+"<br/>";
        st += "<br/><br/>";
        st += "Regards,<br/>KarnelTravel companry";
        KTEmail ktmail = new KTEmail();
        ktmail.Sendmail("littlecatdevil@gmail.com",user.PersonInfor.Email,"Tour check out - Karnel Travel",st);


    }
}
